<template>
    <el-container>
        <el-main>
            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
                <el-form-item label="案例标题" prop="title">
                    <el-input v-model="form.title" />
                </el-form-item>
                <el-form-item label="案例详细" prop="info">
                    <el-input v-model="form.info" type="textarea" :rows="20" placeholder="请输入案例详细" />
                </el-form-item>
                <el-form-item label="是否置顶">
                    <el-radio-group v-model="form.isTop">
                        <el-radio :label="0">否</el-radio>
                        <el-radio :label="1">是</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item>
                    <PrimaryButton text="新增" :click="doAdd" />
                </el-form-item>
            </el-form>
        </el-main>
    </el-container>
</template>

<script>
import { create, goBack } from '@/chaos/functions/mixin/pushcrud';

export default {
    name: 'addCase',
    mixins: [create, goBack],
    data() {
        const rules = {
            title: [
                { required: true, message: '请输入案例标题', trigger: 'blur' }
            ],
            info: [
                { required: true, message: '请输入案例详细', trigger: 'blur' }
            ]
        };
        return {
            domain: 'iya_case',
            indexPath: 'cases',
            form: {
                isTop: 0
            },
            rules
        };
    },
    created() {
        if (!this.$route.params.doctorMu) {
            this.$router.push(this.indexPath);
            return;
        }
        this.form.doctorMu = this.$route.params.doctorMu;
    }
};
</script>
<style scoped>
.el-form {
    width: 800px;
}
</style>
